/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: DELL
 * Date: 2022-08-16
 * Time: 17:55
 */
class Shape{
    public void draw(){
        System.out.println("画图形");
    }
    public void fun(){
        System.out.println("这是父类的方法：：fun");
    }

    public int x = 10;
}
class Triangle extends Shape{
    @Override
    public void draw() {
        System.out.println("画一个三角形");
    }

    public void fun(){
        System.out.println("这是子类Triangle的方法：：fun");
    }

    int x = 20;
}

class Rotundity extends Shape{
    @Override
    public void draw() {
        System.out.println("画一个圆");
    }
}

class Rectangle extends Shape{
    @Override
    public void draw() {
        System.out.println("画一个长方形");
    }
}

class Floower extends Shape{
    @Override
    public void draw() {
        System.out.println("画一朵花");
    }
}

class F{
    public F(){
        //尽量不要在构造器中调用方法
        //如果这个方法被子类重写, 就会触发动态绑定, 但是此时子类对象还没构造完成
        fun();
    }

    public void fun(){
        System.out.println("F.fun");
    }
}

class H extends F{
    private int a = 1;

    @Override
    public void fun() {
        System.out.println("H.fun "+a);
    }

    public H(){
        super();
    }
}

public class Test_0816 {

    public static void drawshape(Shape a){
        a.draw();
    }

    public static void func(Shape b){
        //b.fun();
    }
    public static void main(String[] args) {

/*        Rectangle rectangle = new Rectangle();
        Rotundity rotundity = new Rotundity();
        Floower floower = new Floower();
        Triangle triangle = new Triangle();
        rectangle.draw();
        rotundity.draw();
        floower.draw();
        System.out.println("==========");
        //drawshape(new Triangle());//匿名对象
        drawshape(rectangle);
        drawshape(rotundity);
        drawshape(floower);

        Shape shape = new Triangle();
        func(shape);
        System.out.println(shape.x);*/

        H h = new H();  //根据继承调用顺序可以知道 打印的 a 先为0  在赋值为 1

    }
}
